import { defineConfig, loadEnv } from "vite";
// import UnoCSS from 'unocss/vite'
import uni from "@dcloudio/vite-plugin-uni";

// https://vitejs.dev/config/
export default async ({ mode } : { mode : any }) => {
	const UnoCSS = (await import("unocss/vite")).default;
	const VITE_PROXY_API = loadEnv(mode, process.cwd()).VITE_PROXY_API;
	return defineConfig({
		plugins: [uni(), UnoCSS()],
		// 设置scss的api类型为modern-compiler
		css: {
			preprocessorOptions: {
				scss: {
					api: "modern-compiler",
					silenceDeprecations: ["legacy-js-api"]
				}
			}
		},
		server: {
			host: "0.0.0.0",
			open: true,
			proxy: {
				"/api": {
					target: VITE_PROXY_API,
					changeOrigin: true
				}
			}
		}
	});
};